package net.neptech.model.appointment;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.persistence.*;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import net.neptech.utils.SnowflakeIdGenerator;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;

import java.time.Instant;
import java.util.Date;
import java.util.Map;

@Data
@Comment("病例表")
@Entity
@Table(name = "medical_case")
@TableName("medical_case")
public class MedicalCase {
    @Id
    @Comment("主键")
    @GenericGenerator(name = "snowflake", type = SnowflakeIdGenerator.class)
    @GeneratedValue(generator = "snowflake")
    @Column(name = "id", nullable = false)
    @TableId
    private Long id;


    @Comment("患者ID（不做外键）")
    @Column(name = "patient_id", nullable = false)
    private Long patientId;


    @Comment("主诉")
    @Column(name = "chief_complaint", nullable = false)
    private String chiefComplaint;

    @Comment("现病史/既往史")
    @Lob
    @Column(name = "history")
    private String history;
    @Comment("科室ID")
    @Column(name = "dept_id", nullable = false)
    private Long deptId;

    @Comment("病例图片URL列表（JSON数组）")
    @Column(name = "images")
    @JdbcTypeCode(SqlTypes.JSON)
    private Map<String, Object> images;


    @Comment("创建时间")
    @ColumnDefault("CURRENT_TIMESTAMP")
    @Column(name = "created_at", nullable = false, insertable = false, updatable = false)
    private Date createdAt;


    @Comment("更新时间")
    @ColumnDefault("CURRENT_TIMESTAMP")
    @Column(name = "updated_at", nullable = false, insertable = false, updatable = true)
    private Date updatedAt;

}